Skip to content

fix: parse Snowflake ARRAY cast types - #2933

Merged
manticore-projects merged 1 commit into
JSQLParser:masterfrom
harryfoster2006:fix/snowflake-array-cast-parse-failure
Nov 16, 2026
Merged

manticore-projects merged 1 commit into
JSQLParser:masterfrom
harryfoster2006:fix/snowflake-array-cast-parse-failure

Conversation

@harryfoster2006

Copy link
Copy Markdown
Contributor

Summary

Snowflake queries that cast a semi-structured value to ARRAY failed to parse, e.g. SELECT user.value:subscription_groups::ARRAY FROM ....

ColDataType() accepted the other Snowflake semi-structured type names (VARIANT, OBJECT) but not ARRAY. The grammar tokenises ARRAY as K_ARRAY_LITERAL, and that token wasn't in the allowed list. This PR adds K_ARRAY_LITERAL to the list.

Changes

  • JSqlParserCC.jjt: allow K_ARRAY_LITERAL as a ColDataType.
  • SelectTest.java: add tests for the cases below.

Tests

  • testSnowflakeArrayCastOnVariantPathInFlatten is the original failing query. It has a CREATE TABLE ... AS over a CTE, with LATERAL FLATTEN and user.value:path::ARRAY.
  • testSnowflakeArrayCastShapes covers x::ARRAY, x:y::ARRAY and CAST(x AS ARRAY).
  • testSnowflakeCastsAndLateralFlattenRegression checks that the following still parse:
    • x::INT ARRAY
    • ::VARIANT, ::OBJECT and ::STRING casts
    • a plain LATERAL FLATTEN

@manticore-projects
manticore-projects merged commit 2cd2337 into JSQLParser:master Nov 16, 2026
10 checks passed
@manticore-projects

Copy link
Copy Markdown
Contributor

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants